<?php
echo Html::script('media/lib/jquery-ui/js/jquery-ui-1.8.custom.min.js')."\n";
echo Html::style('media/lib/jquery-ui/development-bundle/themes/base/jquery.ui.all.css')."\n";
echo html::style('media/lib/uploadify/css/uploadify.css')."\n";
echo html::script('media/lib/uploadify/scripts/swfobject.js')."\n";
echo html::script('media/lib/uploadify/scripts/jquery.uploadify.v2.1.0.min.js')."\n";
echo html::script('media/js/jquery.tablednd.js')."\n";
?>
<div style="margin-bottom:20px;">
<?php if($banner['rotation'] == 1) $check_rotation = true; else $check_rotation = false ?>
<?php if($banner['rotation'] == 0) $check_queue = true; else $check_queue = false ?>
<span class="editor_choice">Rotacyjnie: <?php echo form::radio('rotation',1,$check_rotation) ?></span>
<span class="editor_choice">Kolejno: <?php echo form::radio('rotation',0,$check_queue) ?></span>
</div>
<div style="margin-bottom:20px;">
<div id="fileQueue"></div>
Dodaj baner:
<div>
	<input type="file" name="uploadify" id="uploadify" />
</div>
</div>
<table cellspacing="0" class="admin-list" id="table-2">
<thead>
	<tr>
		<th width="50">Podgląd</th>
		<th width="200">Link</th>
		<th width="40">Usuń</th>
	</tr>
</thead>
<tbody>
<?php foreach($units as $u): ?>
<tr id="tcat_<?php echo $u['id']?>">
<td>
<?php
if($u['ext'] == 'swf')
{
?>
<div class="flash_main">
<script type="text/javascript">
<!--
/* FCK swfobject v1.5 */
document.write('<div id="flash2010461924<?php echo $u['id'] ?>" style="width:200; height:100px;"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player<\/a> to see this player.<\/div>');
var params={};
var attributes={};
var flashvars = {};
	params["play"]="true";
	params["menu"]="true";
	params["loop"]="true";
	params["allowfullscreen"]="false";
	params["wmode"]="transparent";
swfobject.embedSWF("upload/banery/<?php echo $banner['folder'] ?>/<?php echo $u['name'] ?>", "flash2010461924<?php echo $u['id'] ?>", 200, 100, "7.0.0", false, flashvars, params, attributes);
/*]]>*/
</script>
</div>
<?php
}else{
	echo html::image('upload/banery/'.$banner['folder'].'/'.$u['name'],array('alt'=>'','title'=>'','width'=>200));
}
?>
</td>
<td>
<div style="float:left;"><input id="url_<?php echo $u['id'] ?>" type="text" size="50" name="url" value="<?php echo $u['url'] ?>" /></div>
<div style="float:left;"><button onclick="changeUrl(<?php echo $u['id'] ?>)" class="input-submit">zmień</button></div>
</td>
<td>
<a href="admin/delbanner/<?php echo $u['id'] ?>" title="usuń" onclick="return confirm('Na pewno usunąć?')"><?php echo html::image('media/img/cross.png',array('alt'=>'usuń')) ?></a>
</td>
</tr>
<?php endforeach ?>
</tbody>
</table>
<script type="text/javascript">
<!--
window.onload = startdnd;
$(document).ready(function() {
	$("input[name=rotation]").click(function(){
		var val = $(this).val();
		$.ajax({
			type: "GET",
			url: "index.php/admin/changerotation",
			data: "banner_id=<?php echo $banner['id'] ?>&val="+val,
			error: function(xhr, desc, e) {
			   alert(xhr.responseText);
			},
			success: function(msg){
				//confirmFlash('ok','Tryb wyświetlania został zmieniony');
			}
		});
	})
	$("#uploadify").uploadify({
		'uploader'       : '<?php echo Url::base(false,true) ?>media/lib/uploadify/scripts/uploadify.swf',
		'script'         : '<?php echo Url::base(false,true) ?>uploadify/banner-<?php echo $banner['id'] ?>',
		'cancelImg'      : '<?php echo Url::base(false,true) ?>media/lib/uploadify/cancel.png',
		'folder'         : '<?php echo Kohana::$base_url ?>upload/banery/<?php echo $banner['folder'] ?>/',
		'queueID'        : 'fileQueue',
		'auto'           : true,
		'buttonText'	 : 'PRZEGLADAJ',
		'fileDesc' : 'Obraz (*.jpg;*.jpeg;*.gif;*.png;*.swf)',
		'fileExt' : '*.jpg;*.jpeg;*.gif;*.png;*.swf',
		//'buttonImg'		 : 'media/css/img_admin/wybierz_pliki.png',
		'width'			 : '110',
		'height'		 : '30',
		'multi'          : true,
		'onAllComplete': function(a, b, c, d, e){
                    //alert(b.toSource());
					location.reload();
                  }
	});
})
function startdnd(){
	//$("#table-2 tr:even").addClass("alt");
	$("#table-2").tableDnD({
		onDragClass: "myDragClass",
		onDrop: function(table, row) {
			var rows = table.tBodies[0].rows;
			var debugStr = "";
			for (var i=0; i<rows.length; i++) {
				debugStr += rows[i].id+"-";
			}
			//alert(debugStr);return false;
			// zapis nowego uporządkowania
			$.ajax({
				type: "GET",
				url: "index.php/admin/bannerorder",
				data: "order="+debugStr,
				success: function(msg){
				}
			});
		},
		onDragStart: function(table, row) {
			//$("#debugArea").html("Started dragging row "+row.id);
		}
	});
}
function changeUrl(inp){
	var url = $("#url_"+inp).val();
	$.ajax({
		type: "GET",
		url: "index.php/admin/changebannerurl",
		data: "url="+url+"&id="+inp,
		error: function(xhr, desc, e) {
           alert(xhr.responseText);
        },
		success: function(msg){
			confirmFlash('ok','Adres URL został zmieniony');
		}
	});
}
-->
</script>